package com.itheima.wms.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.wms.common.service.CrudServiceImpl;
import com.itheima.wms.common.service.ICrudService;
import com.itheima.wms.dao.LocationMapper;
import com.itheima.wms.dto.LocationDTO;
import com.itheima.wms.entity.LocationEntity;
import com.itheima.wms.service.LocationService;
import com.itheima.wms.vo.LocationDetailVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class LocationServiceImpl extends CrudServiceImpl<LocationMapper,LocationEntity> implements LocationService {

    @Autowired
    private LocationMapper locationMapper;
    /**
     * 更新库位
     *
     * @param locationDTO
     * @return
     */
    @Override
    public LocationEntity update(LocationDTO locationDTO) {
        locationMapper.updateLocation(locationDTO);
        LocationEntity locationEntity = locationMapper.selectById(locationDTO.getId());
        return locationEntity;
    }

    @Override
    public IPage<LocationDetailVO> pageDetail(Page<LocationDetailVO> page, Map map) {
        map.put("descs","wl.create_time");
        IPage<LocationDetailVO> iPage = this.baseMapper.selectLocationDetail(page,map);
        return iPage;
    }

    /**
     * 查询库位信息
     *
     * @param map
     * @return
     */
    @Override
    public List<LocationDetailVO> listDetail(Map map) {
        map.put("ascs","wl.code");
        return this.baseMapper.selectLocationDetail(map);
    }
}
